﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PPI.Client.Logic.Inspection;
using PPI.Entities.Inspections;

namespace PPI
{
    public partial class frmAutodetermine : frmBase
    {
        private List<EInspectionStructure> m_Structures;
        private string m_connectionString;
        private Int32 m_meters;

        public List<EInspectionStructure> Structures
        {
            get { return m_Structures; }
            set { m_Structures = value; }
        }

        public string connectionString
        {
            get { return m_connectionString; }
            set { m_connectionString = value; }
        }

        public int Meters
        {
            get { return m_meters; }
            set { m_meters = value; }
        }

        public frmAutodetermine()
        {
            InitializeComponent();
            base.MenuMain.Visible = false;
            this.FormSize = FormSizes.Medium;
            this.CloseEnabled = false;
        }

        private void Autodetermine()
        {
            m_Structures = LInspectionStructure.Autodetermine(m_Structures, m_meters, m_connectionString);
        }

        private void frmAutodetermine_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void frmAutodetermine_Load(object sender, EventArgs e)
        {
            Application.DoEvents();
            m_BackgroundWorkerLoad.RunWorkerAsync();
        }

        protected override void LoadDoWork(object sender, DoWorkEventArgs e)
        {
            Autodetermine();
        }
        protected override void LoadCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.Close();
        }
    }
}
